package com.example.demo.controller;

import com.example.demo.dto.SysJobPO;
import com.example.demo.enums.SysJobStatus;
import com.example.demo.service.SysJob;
import com.example.demo.service.SysJobRepository;
import com.example.demo.util.CronTaskRegistrar;
import com.example.demo.util.SchedulingRunnable;
import com.example.demo.util.springUtil.OperationResUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

@Controller
public class HelloController {
@Autowired
private SysJobRepository sysJobRepository;
@Autowired
private SysJob sysJob ;



    @ResponseBody
    @RequestMapping("/hello")
    public void hello() {
        System.out.println("hello world");
    }

    /**
     * 前段 传递任务信息 这里新建对象
     */
    @ResponseBody
    @RequestMapping("/add")
    public void add() {
        SysJobPO helloJob = new SysJobPO(0001, "demoTask","test","","0/10 * * * * ? ",0,"",new Date(),new Date());
        sysJob.addJob(helloJob);
    }

    @ResponseBody
    @RequestMapping("/change")
    public void change() {
        SysJobPO helloJob = new SysJobPO(0001, "demoTask","taskNoParams","","0/5 * * * * ? ",0,"",new Date(),new Date());
        sysJob.editJob(helloJob);
    }

    @ResponseBody
    @RequestMapping("/del")
    public void del() {
        SysJobPO helloJob = new SysJobPO(0001, "demoTask","taskNoParams","","0/5 * * * * ? ",0,"",new Date(),new Date());
        sysJob.delJob(helloJob);
    }





}
